package com.yulinlin.websocket.node.consume;

import com.corundumstudio.socketio.SocketIOServer;
import com.yulinlin.websocket.common.domain.FrameMessage;
import com.yulinlin.websocket.common.domain.TopicEnum;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TopicConsumer extends RedisConsumer<FrameMessage> {


    @Autowired
    public SocketIOServer socketIoServer;



    @SneakyThrows
    public void run(FrameMessage data){
      /*  socketIoServer.getRoomOperations(data.getTopic())
                .sendEvent(
                        data.getEvent(),
                        JSONUtils.serializeObject(data.getData()),
                        data.getData()
                );*/
        log.info(data.toString());
    }

    @Override
    public String getChannel() {
        return TopicEnum.websocket;
    }
}
